<?php ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>管理员登陆界面</title>
    <style>
        .content{
            margin: 100px 400PX auto 500px;
            width: 600px;
            height: 400px;
            border: solid grey 1px;
            background-color: #06b7c8;0

        }
        h1{
            text-align:center;
            padding: 50px 0 30px 0;
            font-family:impact
        }
        table{
            margin-left: 150px;
            font-size:35px;
        }

        tr{
            font-family: 华文行楷;
        }
        td{font-size:4px;}
        .button input{
            width: 100px;
            height: 30px;
            margin: 30px;
            font-size: 16px;
            text-align: center;
            background:#999;
            border-radius: 10px;
        }
        .button input:hover{background:#1263be;}
        body{background:url("imag/2.jpg")}

    </style>
</head>
<body>
<div class="content">
    <h1>管理员登陆</h1>
    <form name="reg" method="post">
        <table>
            <tr>
                <th>账号：</th>
                <td><input type="text" placeholder="请输入用户名" name="username"/></td>
            </tr>
            <tr>
                <th>密码：</th>
                <td><input type="password" placeholder="请输入密码" name="password"/></td>
            </tr>
            </td><tr>
                <td colspan="2" class="button">
                    <input type="submit" value="登陆" />
                    <input type="reset" value="重置" />
                </td>
            </tr>
        </table>
    </form>
</div>
<?php
if (!empty($_POST)){
    $username=isset($_POST['username'])?($_POST['username']):'';
    $password=isset($_POST['password'])?($_POST['password']):'';
    $link=mysqli_connect('localhost','root','');
    if(!$link){
        die('连接数据库失败!'.mysqli_error($link));
    }
    mysqli_query($link,'set names utf8');
    mysqli_query($link,'use jfgl');
    $username=mysqli_real_escape_string($link,$username);
    $sql = "select `administrator_password`  from`administrator` where `idadministrator`='$username'";
    if ($res=mysqli_query($link,$sql)){
        $row=mysqli_fetch_assoc($res);
        if($password==$row['administrator_password']){
            header('Location:home.php');
            die;
        }else {
            echo '用户密码错误！';
        }

    }
}
?>
</body>
</html>